#ifndef UNITTEST_H_INCLUDED
#define UNITTEST_H_INCLUDED

#include "StackAllocator.h"

namespace CEngine {

class UnitTest {
    public:

        struct Test{
            CHAR*   testName;
            U8      groupID;
            bool    passed;
        };

        enum TestType {
            Equal,
            NotEqual,
            LessThan,
            GreaterThan,
            LessOrEqual,
            GreaterOrEqual,
            Null,
            NotNull
        };

        ///UnitTest constructor.
        ///allows for up to 255 groups and 1024 tests.
        UnitTest(void);

        ///Destructor.
        ~UnitTest(void);

        ///Creates a test group, copies the string to the stack, and returns the groupID.
        U8
        createTestGroup(const CHAR* testGroup);

        ///Creates a test with the given name and results based on comparing result against expectedResult.
        ///Comparison is set by testType. If Null or NotNull is used, expectedResult will not be used.
        ///test is not created if the group doesn't exist.
        template<class Input1, class Input2> void
        test(const U8 groupID, const CHAR* testName, const Input1& result, const Input2& expectedResult, const TestType testType = Equal);

        ///Creates a test with the given name and results based on result.
        ///Comparison must be Null or NotNull.
        ///test is not created if the group doesn't exist.
        template<class Input> void
        test(const U8 groupID, const CHAR* testName, const Input& result, const TestType testType = Null);

        ///prints the results to console.
        void
        printResults(void) const;

    private:

        StackAllocator  stack;
        CHAR**          groupName;
        Test*           tests;
        U32             testCount;
        U8              groupCount;
};

}

#include "UnitTestCore.h"

#endif // UNITTEST_H_INCLUDED
